package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4

infix fun<T:Number,V: Vector2<T, V>> Vector2<T, *>.projectOn(other: Vector2<T, V>) = other * dot(other) / other.squaredLength
infix fun<T:Number,V: Vector3<T, V>> Vector2<T, *>.projectOn(other: Vector3<T, V>) = other * dot(other) / other.squaredLength
infix fun<T:Number,V: Vector4<T, V>> Vector2<T, *>.projectOn(other: Vector4<T, V>) = other * dot(other) / other.squaredLength

infix fun<T:Number,V: Vector2<T, V>> Vector3<T, *>.projectOn(other: Vector2<T, V>) = other * dot(other) / other.squaredLength
infix fun<T:Number,V: Vector3<T, V>> Vector3<T, *>.projectOn(other: Vector3<T, V>) = other * dot(other) / other.squaredLength
infix fun<T:Number,V: Vector4<T, V>> Vector3<T, *>.projectOn(other: Vector4<T, V>) = other * dot(other) / other.squaredLength

infix fun<T:Number,V: Vector2<T, V>> Vector4<T, *>.projectOn(other: Vector2<T, V>) = other * dot(other) / other.squaredLength
infix fun<T:Number,V: Vector3<T, V>> Vector4<T, *>.projectOn(other: Vector3<T, V>) = other * dot(other) / other.squaredLength
infix fun<T:Number,V: Vector4<T, V>> Vector4<T, *>.projectOn(other: Vector4<T, V>) = other * dot(other) / other.squaredLength
